package com.juku2024.juku.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.juku2024.juku.R
import com.juku2024.juku.model.CategorySearchTagModel

class CategorySearchTagItemAdapter(datas: ArrayList<CategorySearchTagModel>?) :
    BaseQuickAdapter<CategorySearchTagModel, BaseViewHolder>(R.layout.item_category_search_tag_text, datas) {

    override fun convert(holder: BaseViewHolder, item: CategorySearchTagModel) {
        holder.setText(R.id.tvCategoryItem, item.name)
        val colorRes = if (item.isSelected) {
            R.color.color_text_light
        } else {
            R.color.color_text_dark
        }
        holder.setTextColorRes(R.id.tvCategoryItem, colorRes)

        val bgRes = if (item.isSelected) {
            R.drawable.shape_category_search_text
        } else {
            0
        }
        holder.setBackgroundResource(R.id.tvCategoryItem, bgRes)
    }

}